﻿using DA.AnimGraph;
using UnityEngine.UIElements;

namespace DA.AnimGraph.Editor {

    class SettingData : InspectorDataSource {
        [InspectorField(label: "导出文件拓展名")] public RefField<ExtensionType> extensionType;

        [InspectorField(label: "导出的同时导出资源引用文件")]
        public RefField<bool> exportResourcesWhenExport;
    }

    internal class SettingPane : TrinityPaneBase {

        private SettingData settingData;

        public SettingPane(AGEEnvironment ageEnv) : base(ageEnv) {
            name = "SettingPane";

            settingData = AGEGlobal.GetInstance().setting.ToSettingData();
            DrawUI();
        }
        public void DrawUI() {
            Add(leftContainer);
            Add(middleContainer);
            Add(rightContainer);

            var closeButton = new Button(OnCloseClicked) {
                text = "关闭"
            };
            leftContainer.Add(closeButton);

            settingData.DrawUI(middleContainer, null, OnSettingChange);
        }

        void OnSettingChange() {
            AGEGlobal.GetInstance().setting.Apply(settingData);
        }

        void OnCloseClicked() {
            ageEnv.serviceManager.GetService<OpenInMainContainerService>().Close();
        }

        protected override void OnDrawUI() { }
        protected override void OnClearUI() { }
    }

}
